//package com.telit.android.service.impl;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.telit.android.dao.AppUserLocationDao;
//import com.telit.android.dto.ForesterShortInfoDTO;
//import com.telit.android.entity.AppUserLocation;
//import com.telit.android.feign.UpmsFeignClient;
//import com.telit.android.service.ForestInfoService;
//import com.telit.common.constant.RoleCodeConstants;
//import com.telit.common.dto.SysUserRolePageDto;
//import com.telit.common.enums.ResultCode;
//import com.telit.common.vo.user.Result;
//import com.telit.common.vo.user.SysUserShortVo;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.util.CollectionUtils;
//
//import java.util.ArrayList;
//import java.util.List;
//
//
///**
// * @Auther amy
// * @Describe
// */
//@Service
//public class ForestInfoServiceImpl implements ForestInfoService {
//
//    @Autowired
//    private UpmsFeignClient upmsFeignClient;
//
//    @Autowired
//    private AppUserLocationDao appUserLocationDao;
//
//
//    @Override
//    public List<ForesterShortInfoDTO> listForestPage(String regionCode, String name, Integer status) {
//        List<ForesterShortInfoDTO> recordList = new ArrayList<>();
//        SysUserRolePageDto sysUserRolePageDto = new SysUserRolePageDto();
//        sysUserRolePageDto.setUserName(name);
//        sysUserRolePageDto.setOnlineStatus(status);
//        sysUserRolePageDto.setRoleCode(RoleCodeConstants.ROLE_CODE_FORESTER);
//        sysUserRolePageDto.setRegionCode(regionCode);
//
//        Result<List<SysUserShortVo>> vo = upmsFeignClient.getListForRole(sysUserRolePageDto);
//        if(vo != null && vo.getCode().equals(ResultCode.SUCCESS.getCode())){
//            if(!CollectionUtils.isEmpty(vo.getData())){
//                vo.getData().forEach(user->{
//                    ForesterShortInfoDTO foresterInfoDTO = new ForesterShortInfoDTO();
//                    BeanUtils.copyProperties(user,foresterInfoDTO);
//                    QueryWrapper<AppUserLocation> wrapper = new QueryWrapper<>();
//                    wrapper.eq("user_id",user.getId());
//                    AppUserLocation appUserLocation = appUserLocationDao.selectOne(wrapper);
//                    if(appUserLocation != null){
//                        foresterInfoDTO.setLongitude(appUserLocation.getLongitude());
//                        foresterInfoDTO.setLatitude(appUserLocation.getLatitude());
//                    }
//                    recordList.add(foresterInfoDTO);
//                });
//            }
//        }
//        return recordList;
//    }
//}
